package com.javastudy.autowiredStudy.getrongqi;

import com.javastudy.autowiredStudy.strategy.IntegerToStringOfListConverter;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.stereotype.Service;

/**
 * 获取IOC容器方式之一：
 */
@Service
public class GetIOCByBeanFactoryAware implements BeanFactoryAware {
    private BeanFactory beanFactory;

    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        this.beanFactory = beanFactory;
    }

    public void getIOC() {
        IntegerToStringOfListConverter integerToStringOfListConverter = (IntegerToStringOfListConverter) beanFactory.getBean("integerToStringOfListConverter");
        System.out.println("integerToStringOfListConverter = " + integerToStringOfListConverter);
    }
}
